<?php

include_once('./common.php');
include_once('./vendor/autoload.php');
include_once(S_ROOT.'./source/function_admin.php');
include_once(S_ROOT.'./source/function_ui.php');
$acs = array('index', 'diary', 'user', 'board', 'inform', "chat", "pv", "user_profile", "message",
			'count_user','count_diary','login','diarycomments','resource','resourceadd','recomment',
			'push','getAllRecords','vip','ability','manage','manage_forbidlogin','count_topic',
			'chatgroup', 'antispam', 'send_message', 'activity','manage_group','autoreply','analysis',
			'hotfilter','analysisTCUsers','topic','diaryTopicOfficial','diarytopic_class','diary_class',
			'femaleAuth','femaleAuth_class','user_class','robot', 'chatroom', 'login_class','sendAnnounce_class',
			'shop_class','pack','push_class','attachment','group_class','planner_category_class','admin','activity2','diary2','recommentlist','member2','anonymous',
			'count_class','code','order','subscription','role','withdrawal','subscriptionSort','diarylist','giftList','article_class','deposited','member','garbage','statistics',
            'management','planner_class','accounts','commentary'
);

// log记录
global $_LOGGER;
$_LOGGER = new Katzgrau\KLogger\Logger(__DIR__.'/data/logs');

//判断是否登陆
if ($_POST['ac'] == 'login' || empty($_SESSION['user']['adminUid']))
{
//    include_once(S_ROOT.'./source/admin_login_class.php');
 	include_once(S_ROOT.'./source/admin_login.php');
	exit;
}


// 判断是否已经在别处登录
if ($_SESSION['user']['adminUid']){
    $param = array(
            'do' => 'getAdminUser',
            'format' => 'json',
            'adminUid' => $_SESSION['user']['adminUid'],
    );
    
    $content  = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->errorNo){
        session_destroy();
        include_once(S_ROOT.'./source/admin_login.php');
        exit;
    }
}

$ac = (empty($_GET['ac']) || !in_array($_GET['ac'], $acs))?'user':$_GET['ac'];
$op = empty($_GET['op'])?'':$_GET['op'];

//菜单
$actives = array($ac => ' class="selected"');
include_once(S_ROOT.'./source/AdminBase.class.php');
include_once(S_ROOT.'./source/admin_'.$ac.'.php');
// 模板绝对路径   template\admin\diary.html
if (!in_array($_GET['ac'],array('diarytopic_class', 'diary_class', 'user_class', 'login_class', 'attachment', 'count_class','article_class','commentary'))) {
    include_once template("admin/".$ac);
}
